-- Create table
create table TM_DRAWINGEMAILINFORMATION
(
  id               VARCHAR2(600) not null,
  drawingid        VARCHAR2(600),
  drawingname      VARCHAR2(600),
  drawingnumber    VARCHAR2(600),
  drawingversion   VARCHAR2(600),
  drawingbegindate VARCHAR2(600),
  drawingenddate   VARCHAR2(600),
  applyuser        VARCHAR2(600),
  dccflag          VARCHAR2(600),
  attr2            VARCHAR2(600),
  attr3            VARCHAR2(600),
  attr4            VARCHAR2(600),
  attr5            VARCHAR2(600),
  attr6            VARCHAR2(600),
  attr7            VARCHAR2(4000),
  attr8            VARCHAR2(4000),
  attr9            DATE,
  attr10           DATE,
  drawingstates    VARCHAR2(600)
)
tablespace USERS
  pctfree 10
  initrans 1
  maxtrans 255
  storage
  (
    initial 24K
    next 24K
    minextents 1
    maxextents unlimited
  );
-- Add comments to the columns 
comment on column TM_DRAWINGEMAILINFORMATION.id
  is 'id';
comment on column TM_DRAWINGEMAILINFORMATION.drawingid
  is '图纸ID';
comment on column TM_DRAWINGEMAILINFORMATION.drawingname
  is '图纸名称';
comment on column TM_DRAWINGEMAILINFORMATION.drawingnumber
  is '图纸编号';
comment on column TM_DRAWINGEMAILINFORMATION.drawingversion
  is '图纸版本';
comment on column TM_DRAWINGEMAILINFORMATION.drawingbegindate
  is 'DCC发布完成时间';
comment on column TM_DRAWINGEMAILINFORMATION.drawingenddate
  is '转正式时间';
comment on column TM_DRAWINGEMAILINFORMATION.applyuser
  is '申请人';
comment on column TM_DRAWINGEMAILINFORMATION.dccflag
  is 'DCC发布之后废弃标识';
comment on column TM_DRAWINGEMAILINFORMATION.attr2
  is '备用2';
comment on column TM_DRAWINGEMAILINFORMATION.attr3
  is '备用3';
comment on column TM_DRAWINGEMAILINFORMATION.attr4
  is '备用4';
comment on column TM_DRAWINGEMAILINFORMATION.attr5
  is '备用5';
comment on column TM_DRAWINGEMAILINFORMATION.attr6
  is '备用6';
comment on column TM_DRAWINGEMAILINFORMATION.attr7
  is '备用7';
comment on column TM_DRAWINGEMAILINFORMATION.attr8
  is '备用8';
comment on column TM_DRAWINGEMAILINFORMATION.attr9
  is '备用9';
comment on column TM_DRAWINGEMAILINFORMATION.attr10
  is '备用10';
comment on column TM_DRAWINGEMAILINFORMATION.drawingstates
  is '监控处理状态';
-- Create/Recreate primary, unique and foreign key constraints 
alter table TM_DRAWINGEMAILINFORMATION
  add constraint EMAILPK_ID primary key (ID)
  using index 
  tablespace USERS
  pctfree 10
  initrans 2
  maxtrans 255
  storage
  (
    initial 64K
    next 1M
    minextents 1
    maxextents unlimited
  );
  ----创建序列
create sequence TM_DRAWINGEMAILINFORMATION_SEQ
increment by 1 
start with 1
nomaxvalue
nominvalue
nocache;

----创建触发器
create or replace trigger TM_DRAWINGEMAILINFORMATION
before insert on TM_DRAWINGEMAILINFORMATION
for each row
begin
select TM_DRAWINGEMAILINFORMATION_SEQ.nextval into :new.id from dual;
end;